import axios from 'axios';
import ngrogress from 'nprogress';
const request = axios.create({
    baseURL:'/api',
    timeout:10000
});
request.interceptors.request.use((config)=>{
    ngrogress.start();
    if(localStorage.token){
        config.headers.Authorization = localStorage.token;
    }
    return config;
});
request.interceptors.response.use(res=>{
    ngrogress.done();
    return res.data;
},err=>{
    return new Error(err);
});

export default request;